package com.rural.bus.driver.fragment;

import java.util.ArrayList;
import java.util.List;

import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.TextView;

import com.rural.bus.driver.MyApplication;
import com.rural.bus.driver.OrderDealActivity;
import com.rural.bus.driver.R;
import com.rural.bus.driver.adapter.NewOrderAdapter;
import com.rural.bus.driver.config.MyPreferenceManager;
import com.rural.bus.driver.config.PreferenceKey;
import com.rural.bus.driver.model.Order;
import com.rural.bus.driver.utils.CommonTools;
import com.rural.bus.driver.view.CircleImageView;
import com.rural.bus.driver.view.xlist.XListView;
import com.squareup.picasso.Picasso;

public class MyAccountFragment extends BaseFragment{

	private CircleImageView userimg;
	private TextView username, tv_car_number, tv_car_type, tv_car_color, tv_my_phone, tv_my_account_balance;

	private String userId;


	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
		View view = inflater.inflate(R.layout.activity_my_account, container, false);
		initViewWithData(view);
		return view;
	}

	private void initViewWithData(View view) {
		userId = MyApplication.driverInfo.drivId;

		userimg = (CircleImageView) view.findViewById(R.id.avatar_pic);
		username = (TextView) view.findViewById(R.id.user_name);

		tv_car_number = (TextView) view.findViewById(R.id.tv_car_number);
		tv_car_type = (TextView) view.findViewById(R.id.tv_car_type);
		tv_car_color = (TextView) view.findViewById(R.id.tv_car_color);
		tv_my_phone = (TextView) view.findViewById(R.id.tv_my_phone);
		tv_my_account_balance = (TextView) view.findViewById(R.id.tv_my_account_balance);
		
		if (!CommonTools.isEmpty(MyApplication.driverInfo.name)) {
			username.setText(MyApplication.driverInfo.name);
		}

		if (!CommonTools.isEmpty(MyApplication.driverInfo.drivPhoto)) {
			Picasso.with(getActivity()).load(MyApplication.driverInfo.drivPhoto).error(R.drawable.default_headimg).into(userimg);
		}

		if (!CommonTools.isEmpty(MyApplication.driverInfo.cardNum)) {
			tv_car_number.setText(MyApplication.driverInfo.cardNum);
		}

		if (!CommonTools.isEmpty(MyApplication.driverInfo.name)) {
			tv_car_color.setText(MyApplication.driverInfo.name);
		}

		switch (MyApplication.driverInfo.carType) {
		case 1:
			tv_car_type.setText("舒服车型");
			break;
		case 2:
			tv_car_type.setText("商务车型");
			break;
		case 3:
			tv_car_type.setText("豪华车型");
			break;
		default:
			tv_car_type.setText("经济车型");
			break;
		}

		if (!CommonTools.isEmpty(MyApplication.driverInfo.phone)) {
			tv_my_phone.setText(MyApplication.driverInfo.phone);
		}

		if (!CommonTools.isEmpty(MyApplication.driverInfo.name)) {
			tv_my_account_balance.setText(MyApplication.driverInfo.name);
		}
	}

}
